#ifndef LARGEFILE_MMAPFILE_H_
#define LARGEFILE_MMAPFILE_H_

#include "common.h"
#include <stdint.h>

namespace zsyuung_fs
{
    namespace largefile
    {
        struct MMapOption
        {
            int32_t max_mmap_size_;         
            int32_t first_mmap_size_;       
            int32_t per_mmap_size_;     
        };


        class MMapFile          
        {
        public:
            MMapFile();
            explicit MMapFile(const int fd);
            MMapFile(const struct MMapOption& mmap_option, const int fd);
            ~MMapFile();
            
            bool sync_file();              
            bool map_file(const bool write = false);    
            void* get_data() const;         
            int32_t get_size() const;       
            
            bool munmap_file();             
            bool remap_file();              

        private:
            bool ensure_file_size(const int32_t size);  

        private:
            int32_t size_;                  
            int fd_;                        
            void* data_;                    
            struct MMapOption mmap_file_option_;
        };

    }
}

#endif
